package com.geologyoa.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;

import com.geologyoa.domain.Dwzz01;
import com.geologyoa.domain.Xmqk01;
import com.geologyoa.service.SystemManager;
import com.geologyoa.service.SystemManagerImpl;

public class SerachXmqk01Servlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
       doPost(request,response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//4008288988
		SystemManager sys=new SystemManagerImpl();
		String xmqk01003=request.getParameter("XMQK01003");
		String xmqk01005=request.getParameter("XMQK01005");
		String xmqk01006=request.getParameter("XMQK01006");
        String minfy=request.getParameter("MINFY");
		String maxfy=request.getParameter("MAXFY");
		String minjgtime=request.getParameter("MINJGTIME");
		String maxjgtime=request.getParameter("MAXJGTIME");
		///add  by  cuiyi 20130430  
		String xmqk01009 = request.getParameter("XMQK01009");//c承担单位
		
		List<Xmqk01> xmqkList=sys.SerachXmqk01(xmqk01003, xmqk01005, xmqk01006, minfy, maxfy, minjgtime, maxjgtime,xmqk01009);
		Document document=DocumentHelper.createDocument();
		if(xmqkList!=null)
		{
			Element fwlistElement =document.addElement("xmqkList");
			fwlistElement.addAttribute("size", (new StringBuilder(String.valueOf(xmqkList.size()))).toString());
			Xmqk01 xmqk01;
			Element fwElement;
			DecimalFormat df=new DecimalFormat("0.00");
			for(Iterator iterator=xmqkList.iterator();iterator.hasNext();)
			{
				xmqk01 = (Xmqk01)iterator.next();
				fwElement=fwlistElement.addElement("xmqkInfo");
				fwElement.addAttribute("XMQK01001", xmqk01.getXmqk01001().toString());
				fwElement.addAttribute("XMQK01002", xmqk01.getXmqk01002());
				fwElement.addAttribute("XMQK01003", xmqk01.getXmqk01003());
				fwElement.addAttribute("XMQK01004", xmqk01.getXmqk01004());
				fwElement.addAttribute("XMQK01005", xmqk01.getXmqk01005());
				fwElement.addAttribute("XMQK01006", xmqk01.getXmqk01006());
				fwElement.addAttribute("XMQK01007", xmqk01.getXmqk01007());
				fwElement.addAttribute("XMQK01008", xmqk01.getXmqk01008());
				fwElement.addAttribute("XMQK01009", xmqk01.getXmqk01009());
				fwElement.addAttribute("XMQK01010", xmqk01.getXmqk01010());
				fwElement.addAttribute("XMQK01011", xmqk01.getXmqk01011());
				fwElement.addAttribute("XMQK01012",xmqk01.getXmqk01012());
				fwElement.addAttribute("XMQK01013",xmqk01.getXmqk01013());
				fwElement.addAttribute("XMQK01014",xmqk01.getXmqk01014());
				fwElement.addAttribute("XMQK01015",xmqk01.getXmqk01015());
				fwElement.addAttribute("XMQK01016",xmqk01.getXmqk01016());
				fwElement.addAttribute("XMQK01017",df.format(xmqk01.getXmqk01017()));
				fwElement.addAttribute("XMQK01018",df.format(xmqk01.getXmqk01018()));
				fwElement.addAttribute("XMQK01019",df.format(xmqk01.getXmqk01019()));
				fwElement.addAttribute("XMQK01020",df.format(xmqk01.getXmqk01020()));
				fwElement.addAttribute("XMQK01021",df.format(xmqk01.getXmqk01021()));
				fwElement.addAttribute("XMQK01022",df.format(xmqk01.getXmqk01022()));
				fwElement.addAttribute("XMQK01023",df.format(xmqk01.getXmqk01023()));
				fwElement.addAttribute("XMQK01024",df.format(xmqk01.getXmqk01024()));
				fwElement.addAttribute("XMQK01025",xmqk01.getXmqk01025());
				fwElement.addAttribute("XMQK01026",xmqk01.getXmqk01026());
				fwElement.addAttribute("XMQK01027",xmqk01.getXmqk01027());
				fwElement.addAttribute("XMQK01028",xmqk01.getXmqk01028());
				fwElement.addAttribute("XMQK01029",xmqk01.getXmqk01029());
				fwElement.addAttribute("XMQK01030",xmqk01.getXmqk01030());
				fwElement.addAttribute("XMQK01031",xmqk01.getXmqk01031());
				fwElement.addAttribute("XMQK01032",xmqk01.getXmqk01032());
				fwElement.addAttribute("XMQK01033",xmqk01.getXmqk01033());
				fwElement.addAttribute("XMQK01034",xmqk01.getXmqk01034());
				fwElement.addAttribute("XMQK01035",xmqk01.getXmqk01035());
				fwElement.addAttribute("XMQK01036",xmqk01.getXmqk01036());
				fwElement.addAttribute("XMQK01037",df.format(xmqk01.getXmqk01037()));
				fwElement.addAttribute("XMQK01038",xmqk01.getXmqk01038());
				fwElement.addAttribute("XMQK01039",xmqk01.getXmqk01039());
				fwElement.addAttribute("XMQK01040",xmqk01.getXmqk01040());
				fwElement.addAttribute("XMQK01041",xmqk01.getXmqk01041());
				fwElement.addAttribute("XMQK01042",xmqk01.getXmqk01042());
				fwElement.addAttribute("XMQK01043",df.format(xmqk01.getXmqk01043()));
				fwElement.addAttribute("XMQK01044",df.format(xmqk01.getXmqk01044()));
				fwElement.addAttribute("XMQK01045",df.format(xmqk01.getXmqk01045()));
				fwElement.addAttribute("XMQK01046",df.format(xmqk01.getXmqk01046()));
				fwElement.addAttribute("XMQK01047",df.format(xmqk01.getXmqk01047()));
				fwElement.addAttribute("XMQK01048",xmqk01.getXmqk01048());
				fwElement.addAttribute("XMQK01049",xmqk01.getXmqk01049());
				fwElement.addAttribute("XMQK01050",xmqk01.getXmqk01050());
				fwElement.addAttribute("XMQK01051",xmqk01.getXmqk01051());
				fwElement.addAttribute("XMQK01052",xmqk01.getXmqk01052());
				fwElement.addAttribute("XMQK01053",xmqk01.getXmqk01053());
				fwElement.addAttribute("XMQK01054",xmqk01.getXmqk01054());
				fwElement.addAttribute("XMQK01055",xmqk01.getXmqk01055());
				fwElement.addAttribute("XMQK01056",xmqk01.getXmqk01056());
				fwElement.addAttribute("XMQK01057",xmqk01.getXmqk01057());
				fwElement.addAttribute("XMQK01058",xmqk01.getXmqk01058());
				fwElement.addAttribute("XMQK01059",xmqk01.getXmqk01059());
				fwElement.addAttribute("XMQK01060",df.format(xmqk01.getXmqk01060()));
				fwElement.addAttribute("XMQK01061",xmqk01.getXmqk01061());
				fwElement.addAttribute("XMQK01062",xmqk01.getXmqk01062());
				fwElement.addAttribute("XMQK01063",xmqk01.getXmqk01063());
				fwElement.addAttribute("XMQK01064",xmqk01.getXmqk01064());
				fwElement.addAttribute("XMQK01065",xmqk01.getXmqk01065());
				fwElement.addAttribute("XMQK01066",xmqk01.getXmqk01066());
				fwElement.addAttribute("XMQK01067",xmqk01.getXmqk01067());
				fwElement.addAttribute("XMQK01068",xmqk01.getXmqk01068());
				fwElement.addAttribute("XMQK01069",xmqk01.getXmqk01069());
				fwElement.addAttribute("XMQK01070",xmqk01.getXmqk01070());
				fwElement.addAttribute("XMQK01071",xmqk01.getXmqk01071());
				fwElement.addAttribute("XMQK01072",xmqk01.getXmqk01072());
				fwElement.addAttribute("XMQK01073",df.format(xmqk01.getXmqk01073()));
				fwElement.addAttribute("XMQK01074",xmqk01.getXmqk01074());
				fwElement.addAttribute("XMQK01075",xmqk01.getXmqk01075());
				fwElement.addAttribute("XMQK01076",xmqk01.getXmqk01076());
				fwElement.addAttribute("XMQK01077",xmqk01.getXmqk01077());
				fwElement.addAttribute("XMQK01078",xmqk01.getXmqk01078());
				fwElement.addAttribute("XMQK01079",xmqk01.getXmqk01079());
				fwElement.addAttribute("XMQK01080",xmqk01.getXmqk01080());
				fwElement.addAttribute("XMQK01081",xmqk01.getXmqk01081());
				fwElement.addAttribute("XMQK01082",xmqk01.getXmqk01082());
				fwElement.addAttribute("XMQK01083",xmqk01.getXmqk01083());
				fwElement.addAttribute("XMQK01084",xmqk01.getXmqk01084());
				fwElement.addAttribute("XMQK01085",xmqk01.getXmqk01085());
				fwElement.addAttribute("XMQK01086",df.format(xmqk01.getXmqk01086()));
				fwElement.addAttribute("XMQK01087",xmqk01.getXmqk01087());
				fwElement.addAttribute("XMQK01088",xmqk01.getXmqk01088());
				fwElement.addAttribute("XMQK01089",xmqk01.getXmqk01089());
				fwElement.addAttribute("XMQK01090",xmqk01.getXmqk01090());
				fwElement.addAttribute("XMQK01091",xmqk01.getXmqk01091());
				fwElement.addAttribute("XMQK01092",xmqk01.getXmqk01092());
				fwElement.addAttribute("XMQK01093",xmqk01.getXmqk01093());
				fwElement.addAttribute("XMQK01094",xmqk01.getXmqk01094());
				fwElement.addAttribute("XMQK01095",xmqk01.getXmqk01095());
				fwElement.addAttribute("XMQK01096",xmqk01.getXmqk01096());
				fwElement.addAttribute("XMQK01097",xmqk01.getXmqk01097());
				fwElement.addAttribute("XMQK01098",xmqk01.getXmqk01098());
				fwElement.addAttribute("XMQK01099",df.format(xmqk01.getXmqk01099()));
				fwElement.addAttribute("XMQK01100",xmqk01.getXmqk01100());
				fwElement.addAttribute("XMQK01101",xmqk01.getXmqk01101());
				fwElement.addAttribute("XMQK01102",xmqk01.getXmqk01102());
				fwElement.addAttribute("XMQK01103",xmqk01.getXmqk01103());
				fwElement.addAttribute("XMQK01104",xmqk01.getXmqk01104());
				fwElement.addAttribute("XMQK01105",xmqk01.getXmqk01105());
				fwElement.addAttribute("XMQK01106",xmqk01.getXmqk01106());
				fwElement.addAttribute("XMQK01107",xmqk01.getXmqk01107());
				fwElement.addAttribute("XMQK01108",xmqk01.getXmqk01108());
				fwElement.addAttribute("XMQK01109",xmqk01.getXmqk01109());
				fwElement.addAttribute("XMQK01110",xmqk01.getXmqk01110());
				fwElement.addAttribute("XMQK01111",xmqk01.getXmqk01111());
				fwElement.addAttribute("XMQK01112",df.format(xmqk01.getXmqk01112()));
				fwElement.addAttribute("XMQK01113",xmqk01.getXmqk01113());
				fwElement.addAttribute("XMQK01114",xmqk01.getXmqk01114());
				fwElement.addAttribute("XMQK01115",xmqk01.getXmqk01115());
				fwElement.addAttribute("XMQK01116",xmqk01.getXmqk01116());
				fwElement.addAttribute("XMQK01117",xmqk01.getXmqk01117());
				fwElement.addAttribute("XMQK01118",xmqk01.getXmqk01118());
				fwElement.addAttribute("XMQK01119",xmqk01.getXmqk01119());
				fwElement.addAttribute("XMQK01120",xmqk01.getXmqk01120());
				fwElement.addAttribute("XMQK01121",xmqk01.getXmqk01121());
				fwElement.addAttribute("XMQK01122",xmqk01.getXmqk01122());
				fwElement.addAttribute("XMQK01123",xmqk01.getXmqk01123());
				fwElement.addAttribute("XMQK01124",xmqk01.getXmqk01124());
				fwElement.addAttribute("XMQK01125",xmqk01.getXmqk01125());
				fwElement.addAttribute("XMQK01126",xmqk01.getXmqk01126());
				fwElement.addAttribute("XMQK01127",xmqk01.getXmqk01127());
				fwElement.addAttribute("XMQK01128",xmqk01.getXmqk01128().toString());
				fwElement.addAttribute("XMQK01129",xmqk01.getXmqk01129().toString());
				fwElement.addAttribute("XMQK01130",xmqk01.getXmqk01130().toString());
				fwElement.addAttribute("XMQK01131",xmqk01.getXmqk01131().toString());
				fwElement.addAttribute("XMQK01132",xmqk01.getXmqk01132());
				fwElement.addAttribute("XMQK01133",xmqk01.getXmqk01133().toString());
				fwElement.addAttribute("XMQK01134",xmqk01.getXmqk01134().toString());
				fwElement.addAttribute("XMQK01135",xmqk01.getXmqk01135());
				fwElement.addAttribute("XMQK01136",xmqk01.getXmqk01136());
				fwElement.addAttribute("XMQK01137",xmqk01.getXmqk01137());
				
			}
		}
		StringWriter xmlout = new StringWriter();
		XMLWriter output = new XMLWriter(xmlout);
		output.write(document);
		response.setContentType("text/html;charset=utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Expires", "0");
		response.setHeader("Pragma", "No-cache");
		response.getWriter().write(xmlout.toString());
	}

}
